export default defineEventHandler(async (event) => {
  const query = getQuery(event);
  const resourceId = query.resourceId as string;

  // 多领域属性示例数据
  const multiDomainProperties = {
    domains: {
      BUSINESS: {
        schema: [
          {
            id: 'business_1',
            fieldName: 'building_type',
            label: '建筑类型',
            component: 'Select',
            componentProps: {
              placeholder: '请选择建筑类型',
              options: [
                { label: '酒店', value: '酒店' },
                { label: '公寓', value: '公寓' },
                { label: '办公楼', value: '办公楼' },
                { label: '商场', value: '商场' },
                { label: '医院', value: '医院' },
                { label: '学校', value: '学校' },
              ],
              showSearch: true,
            },
            rules: 'required',
            defaultValue: '酒店',
            domain: 'BUSINESS',
            order: 1,
            isActive: true,
          },
          {
            id: 'business_2',
            fieldName: 'floors',
            label: '楼层数',
            component: 'InputNumber',
            componentProps: {
              placeholder: '请输入楼层数',
              min: 1,
              max: 200,
              addonAfter: '层',
            },
            rules: 'required',
            defaultValue: 25,
            domain: 'BUSINESS',
            order: 2,
            isActive: true,
          },
          {
            id: 'business_3',
            fieldName: 'total_rooms',
            label: '房间总数',
            component: 'InputNumber',
            componentProps: {
              placeholder: '请输入房间总数',
              min: 1,
              max: 10_000,
              addonAfter: '间',
            },
            rules: 'required',
            defaultValue: 200,
            domain: 'BUSINESS',
            order: 3,
            isActive: true,
          },
          {
            id: 'business_4',
            fieldName: 'construction_year',
            label: '建造年份',
            component: 'InputNumber',
            componentProps: {
              placeholder: '请输入建造年份',
              min: 1900,
              max: 2030,
              addonAfter: '年',
            },
            rules: 'required',
            defaultValue: 2020,
            domain: 'BUSINESS',
            order: 4,
            isActive: true,
          },
          {
            id: 'business_5',
            fieldName: 'building_area',
            label: '建筑面积',
            component: 'InputNumber',
            componentProps: {
              placeholder: '请输入建筑面积',
              min: 1,
              max: 1_000_000,
              addonAfter: '平方米',
              formatter: (value: number) => `${value.toLocaleString()}`,
              parser: (value: string) => value.replaceAll(/\D/g, ''),
            },
            rules: 'required',
            defaultValue: 15_000,
            domain: 'BUSINESS',
            order: 5,
            isActive: true,
          },
        ],
        data: {
          building_type: '酒店',
          floors: 25,
          total_rooms: 200,
          construction_year: 2020,
          building_area: 15_000,
        },
        config: {
          key: 'BUSINESS',
          name: '业务领域',
          description: '核心业务属性，如价格、房型、设施等',
          icon: 'ant-design:shop-outlined',
          color: '#1890ff',
          visible: true,
          editable: true,
          required: false,
          order: 0,
        },
      },
      OPERATION: {
        schema: [
          {
            id: 'operation_1',
            fieldName: 'channel_status',
            label: '渠道状态',
            component: 'Switch',
            componentProps: {
              checkedChildren: '上架',
              unCheckedChildren: '下架',
            },
            rules: 'required',
            defaultValue: true,
            domain: 'OPERATION',
            order: 1,
            isActive: true,
          },
          {
            id: 'operation_2',
            fieldName: 'inventory_strategy',
            label: '库存策略',
            component: 'Select',
            componentProps: {
              placeholder: '请选择库存策略',
              options: [
                { label: '实时库存', value: 'real_time' },
                { label: '预分配库存', value: 'pre_allocated' },
                { label: '超卖策略', value: 'oversell' },
              ],
            },
            rules: 'required',
            defaultValue: 'real_time',
            domain: 'OPERATION',
            order: 2,
            isActive: true,
          },
          {
            id: 'operation_3',
            fieldName: 'partner_tags',
            label: '合作方标签',
            component: 'Select',
            componentProps: {
              mode: 'multiple',
              placeholder: '请选择合作方标签',
              options: [
                { label: '携程', value: 'ctrip' },
                { label: '美团', value: 'meituan' },
                { label: '飞猪', value: 'fliggy' },
                { label: '去哪儿', value: 'qunar' },
                { label: '同程', value: 'tongcheng' },
              ],
            },
            defaultValue: ['ctrip', 'meituan'],
            domain: 'OPERATION',
            order: 3,
            isActive: true,
          },
        ],
        data: {
          channel_status: true,
          inventory_strategy: 'real_time',
          partner_tags: ['ctrip', 'meituan'],
        },
        config: {
          key: 'OPERATION',
          name: '运营领域',
          description: '运营相关属性，如渠道、库存、合作方等',
          icon: 'ant-design:setting-outlined',
          color: '#52c41a',
          visible: true,
          editable: true,
          required: false,
          order: 1,
        },
      },
      TECHNICAL: {
        schema: [
          {
            id: 'technical_1',
            fieldName: 'api_version',
            label: 'API版本',
            component: 'Input',
            componentProps: {
              placeholder: '请输入API版本号',
            },
            rules: 'required',
            defaultValue: 'v1.0.0',
            domain: 'TECHNICAL',
            order: 1,
            isActive: true,
          },
          {
            id: 'technical_2',
            fieldName: 'environment',
            label: '运行环境',
            component: 'Select',
            componentProps: {
              placeholder: '请选择运行环境',
              options: [
                { label: '开发环境', value: 'dev' },
                { label: '测试环境', value: 'test' },
                { label: '生产环境', value: 'prod' },
              ],
            },
            rules: 'required',
            defaultValue: 'prod',
            domain: 'TECHNICAL',
            order: 2,
            isActive: true,
          },
          {
            id: 'technical_3',
            fieldName: 'api_key',
            label: 'API密钥',
            component: 'Input',
            componentProps: {
              placeholder: '请输入API密钥',
              type: 'password',
            },
            rules: 'required',
            defaultValue: 'sk-1234567890abcdef',
            domain: 'TECHNICAL',
            order: 3,
            isActive: true,
          },
          {
            id: 'technical_4',
            fieldName: 'deployment_date',
            label: '部署日期',
            component: 'DatePicker',
            componentProps: {
              placeholder: '请选择部署日期',
              format: 'YYYY-MM-DD',
            },
            defaultValue: '2024-01-15',
            domain: 'TECHNICAL',
            order: 4,
            isActive: true,
          },
        ],
        data: {
          api_version: 'v1.0.0',
          environment: 'prod',
          api_key: 'sk-1234567890abcdef',
          deployment_date: '2024-01-15',
        },
        config: {
          key: 'TECHNICAL',
          name: '技术领域',
          description: '技术相关属性，如版本、API、环境等',
          icon: 'ant-design:code-outlined',
          color: '#722ed1',
          visible: true,
          editable: true,
          required: false,
          order: 2,
        },
      },
      COMPLIANCE: {
        schema: [
          {
            id: 'compliance_1',
            fieldName: 'certification_status',
            label: '认证状态',
            component: 'Select',
            componentProps: {
              placeholder: '请选择认证状态',
              options: [
                { label: '已认证', value: 'certified' },
                { label: '认证中', value: 'certifying' },
                { label: '未认证', value: 'uncertified' },
              ],
            },
            rules: 'required',
            defaultValue: 'certified',
            domain: 'COMPLIANCE',
            order: 1,
            isActive: true,
          },
          {
            id: 'compliance_2',
            fieldName: 'privacy_level',
            label: '隐私等级',
            component: 'Select',
            componentProps: {
              placeholder: '请选择隐私等级',
              options: [
                { label: '公开', value: 'public' },
                { label: '内部', value: 'internal' },
                { label: '机密', value: 'confidential' },
              ],
            },
            rules: 'required',
            defaultValue: 'internal',
            domain: 'COMPLIANCE',
            order: 2,
            isActive: true,
          },
          {
            id: 'compliance_3',
            fieldName: 'gdpr_compliant',
            label: 'GDPR合规',
            component: 'Switch',
            componentProps: {
              checkedChildren: '合规',
              unCheckedChildren: '不合规',
            },
            defaultValue: true,
            domain: 'COMPLIANCE',
            order: 3,
            isActive: true,
          },
          {
            id: 'compliance_4',
            fieldName: 'audit_notes',
            label: '审计备注',
            component: 'Textarea',
            componentProps: {
              placeholder: '请输入审计备注',
              rows: 3,
            },
            defaultValue: '通过年度安全审计，符合行业标准',
            domain: 'COMPLIANCE',
            order: 4,
            isActive: true,
          },
        ],
        data: {
          certification_status: 'certified',
          privacy_level: 'internal',
          gdpr_compliant: true,
          audit_notes: '通过年度安全审计，符合行业标准',
        },
        config: {
          key: 'COMPLIANCE',
          name: '合规风控',
          description: '合规和风控属性，如资质、状态、隐私等',
          icon: 'ant-design:safety-outlined',
          color: '#fa8c16',
          visible: true,
          editable: true,
          required: false,
          order: 3,
        },
      },
    },
    metadata: {
      version: '1.0.0',
      lastModified: '2024-01-15T10:30:00Z',
      modifiedBy: 'admin',
      domainCount: 4,
      totalFields: 16,
    },
  };

  return {
    success: true,
    data: multiDomainProperties,
    message: '获取多领域属性成功',
  };
});
